package com.woniuxy.provider;

import com.work.framework.pojo.Logs;
import org.apache.ibatis.jdbc.SQL;

/**
 * 〈一句话功能简述〉<br>
 * 〈logs类的provider〉
 *
 * @author jia
 * @create 2019/9/26
 * @since 1.0.0
 */
public class LogsProvider {

//    private Integer id;                 //主键id
//    private String operation_time;       //操作时间
//    private Integer operator;           //操作人
//    private String operation_description;//操作描述
//    private Integer flag;               //软删除
//    private String module;              //模块
//    private String response;            //响应时间
//    private String ip;                  //IP地址
//    private String result;              //操作结果

    public String providerSql(Logs logs) {
        SQL sql = new SQL().SELECT("*").FROM("`logs` l INNER JOIN `user` u ON l.operator=u.uid").WHERE("l.flag=1");

        //账号
        if (logs.getAccount() != null && logs.getAccount().length() != 0) {
            sql.WHERE("u.account like '%" + logs.getAccount() + "%'");
        }
        //时间判断
        if (logs.getStartTime() != null && logs.getStartTime().length() != 0 && logs.getEndTime() != null && logs.getEndTime().length() != 0) {
            sql.WHERE("operation_time between '" + logs.getStartTime() + "' and '" + logs.getEndTime() + "'");
        }
        return sql.toString();
    }
}
